package framework

import (
	"log"
	"net/http"
)

var (
	Router *RouterHandler = new(RouterHandler)
	mux                   = make(map[string]func(http.ResponseWriter, *http.Request))
)

type RouterHandler struct {
}

func (this *RouterHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
	log.Println(r.URL.Path)
	if fuc, ok := mux[r.URL.Path]; ok {
		fuc(w, r)
		return
	}
}

func (this *RouterHandler) Router(relativePath string, handler func(http.ResponseWriter, *http.Request)) {
	mux[relativePath] = handler
}
